<template>
  <div>组合式API-组件,<button @click="handleHome">跳到首页</button></div>
</template>

<script>
import { useRoute, useRouter } from "vue-router"; //Hook函数
export default {
  setup() {
    //无法使用this
    let route = useRoute(); //此处的route等同于this.$route
    console.log("组合式API-useRoute", route.query);

    let router = useRouter(); //此处的router等同于this.$router
    const handleHome = () => {
      router.push("/home");
    };
    return {
      handleHome,
    };
  },
};
</script>

<style lang="scss" scoped></style>
